package dao;

import utils.JdbcUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class EmpDeleteDaoImp implements EmpDeleteDao {
    @Override
    public void delEmp(int id) {
        //通过id删除那个员工数据
        Connection conn=null;
        PreparedStatement sta=null;

        try {
            conn= JdbcUtils.getConnection();
             //编写sql语句
            String sql="delete from t_emp where id=?";
            //获取预编译对象
            sta=conn.prepareStatement(sql);
            //设置值
            sta.setInt(1,id);
            sta.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        JdbcUtils.close(conn,sta);
        }
    }
}
